package com.hua.yuan.http;

import android.util.Log;

import java.util.Map;

/**
 * Created by hy on 2017/3/30.
 * 打印请求的Url
 */

public class ShowUrl {

    /**
     * http
     *
     * @param action  接口名
     * @param hashMap 传入的值
     */
    public static void createPostUrl(String action, Map<String, String> hashMap) {
        if (hashMap != null && hashMap.size() > 0) {
            StringBuilder sb = new StringBuilder();

            int i = 0;

            for (Object o : hashMap.entrySet()) {
                Map.Entry entry = (Map.Entry) o;
                String key = (String) entry.getKey();
                String val = (String) entry.getValue();
                i = i + 1;
                if (i < hashMap.size()) {
                    sb.append(key).append("=").append(val).append("&");
                } else {
                    sb.append(key).append("=").append(val);
                }
            }


            Log.i("Test", BaseUrl.BASE_URL + action + "?" + sb.toString());


        }

    }

    /**
     * https
     *
     * @param action  接口名
     * @param hashMap 传入的值
     */
    public static void createPostUrlSSL(String action, Map<String, String> hashMap) {
        if (hashMap != null && hashMap.size() > 0) {
            StringBuilder sb = new StringBuilder();

            int i = 0;

            for (Object o : hashMap.entrySet()) {
                Map.Entry entry = (Map.Entry) o;
                String key = (String) entry.getKey();
                String val = (String) entry.getValue();
                i = i + 1;
                if (i < hashMap.size()) {
                    sb.append(key).append("=").append(val).append("&");
                } else {
                    sb.append(key).append("=").append(val);
                }
            }


            Log.i("Url", BaseUrl.BASE_URL_SSL + action + "?" + sb.toString());

        }

    }

}
